﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="hot-subject.aspx.cs" Inherits="admin_hot_subject" %>


<%@ Import Namespace="Infrastructure.Utility" %>
<asp:Content ContentPlaceHolderID="titleContent" runat="Server">热门科目设置</asp:Content>
<asp:Content ContentPlaceHolderID="headContent" runat="Server">
    <style type="text/css">
    </style>
</asp:Content>
<asp:Content ContentPlaceHolderID="mainContent" runat="Server">
    <h4>科目热门</h4>
    <form runat="server" class="form-horizontal">
        <div>
            <div class="pull-left" style="margin-bottom: 2px; width: 250px;">
                <div class="input-group">
                    <asp:TextBox class="form-control" aria-describedby="sizing-addon1" placeholder="输入名称检索." runat="server" ID="txtName" onkeydown="if(event.keyCode == 13) $('.searchbutton').click();" />
                    <span class="input-group-addon" style="cursor: pointer;" id="sizing-addon1" onclick="$('.searchbutton').click();"><i class="cus-icon-search">&nbsp;</i></span>
                </div>
                <span class="hidden">
                    <asp:Button runat="server" name="btnPost" CssClass="searchbutton" OnClick="btnPost_Click" UseSubmitBehavior="false" />
                </span>
            </div>
            <div class="pull-right" style="margin-bottom: 2px;">
                <button type="button" class="btn btn-success" onclick="if(checkSelected()) $('.btnHotAll').click();">设为热门</button>
                <button type="button" class="btn btn-danger" onclick="if(checkSelected()) $('.btnUnHotAll').click();">取消热门</button>
                <span class="hidden">
                    <asp:Button runat="server" CssClass="hidden btnHotAll" OnClick="HotAll_Click" CommandName="CHECKALL" />
                    <asp:Button runat="server" CssClass="hidden btnUnHotAll" OnClick="HotAll_Click" CommandName="UNCHECKALL" />
                </span>
            </div>
        </div>
        <input type="hidden" id="txtGoTo" name="txtGoTo" value="0" />
        <table class="table gridview">
            <tr>
                <th>
                    <input type="checkbox" onchange="$(this).parentsUntil('table').find('.selector').attr('checked',this.checked);" />选择
                </th>
                <th>年级</th>
                <th>科目</th>
                <th>
                    <asp:LinkButton runat="server" OnClick="SortByVisits_Click">阅读量<%=SortCol.EndsWith("ASC") ? "↑" : (SortCol.EndsWith("DESC") ? "↓" : string.Empty)  %></asp:LinkButton>
                </th>
                <th>热门</th>
            </tr>
            <asp:Repeater ID="lstGradeSubject" runat="server">
                <ItemTemplate>
                    <tr>
                        <td>
                            <input type="checkbox" class="selector" name="selector" value="<%# Eval("sid") %>" />
                        </td>
                        <td><%#Eval("gname") %></td>
                        <td><%#Eval("sname") %></td>
                        <td><%#Eval("visits") %></td>
                        <td>
                            <input type="checkbox" <%#Eval("hot").To<bool>() == true ? "checked":string.Empty %> value="<%# Eval("sid") %>" />
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>
        <div>
            <div class="btn-group pull-left" role="group">
                <button type="button" class="btn btn-default" onclick="$('#txtGoTo').val('1');$('.gotoindex').click();">1</button>
                <button type="button" class="btn btn-default" onclick="$('#txtGoTo').val('<%=Index-1 %>');$('.gotoindex').click();"><<</button>
                <button type="button" class="btn btn-default" onclick="$('#txtGoTo').val('<%=Index+1 %>');$('.gotoindex').click();">>></button>
                <button type="button" class="btn btn-default" onclick="$('#txtGoTo').val('<%=TotalSize %>');$('.gotoindex').click();"><%=TotalSize %></button>
                <input type="text" class="form-control" style="width: 20px; margin-left: 2px;" placeholder="Go" onkeydown="if(event.keyCode==13) { $('#txtGoTo').val(this.value);$('.gotoindex').click();}" />
                <asp:Button runat="server" CssClass="hidden gotoindex" UseSubmitBehavior="false" OnClick="btnNavigate_Click" />
            </div>
            <div class="pull-right">
                <%=Index %>/<%=TotalSize %>页
            </div>
        </div>
    </form>
</asp:Content>
<asp:Content ContentPlaceHolderID="scriptContent" runat="Server">
    <script type="text/javascript">
        //验证点击删除时，是否勾选了项目。
        function checkSelected() {
            var hasSel = false;
            $(".selector").each(function (index, e) {
                if (this.checked) return hasSel = true;
            });

            if (!hasSel) {
                alert("请勾选需要删除的项目！");
                return false;
            }
            return true;
        }
    </script>
</asp:Content>
